package com.lbj.mall.cart.config;

import com.lbj.mall.cart.interceptor.CartInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class AppWebConfig implements WebMvcConfigurer {

    @Autowired
    private CartInterceptor cartInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 添加拦截器 /** 表示所有请求
        // 让 CartInterceptor 拦截器工作
        registry.addInterceptor(cartInterceptor)
                .addPathPatterns("/**");
    }
}
